package com.xish.api.follow;

import com.mysema.query.sql.SQLQuery;
import com.xish.model.bean.WzmActivityUserfollow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jdbc.query.QueryDslJdbcTemplate;
import org.springframework.stereotype.Repository;

import static com.xish.model.table.QWzmActivityUserfollow.wzmActivityUserfollow;

@Repository
public class FollowRepository {

    @Autowired
    private QueryDslJdbcTemplate jdbcTemplate;

    public WzmActivityUserfollow findFollow(int userId, String uuid) {
        SQLQuery query = jdbcTemplate.newSqlQuery()
                .from(wzmActivityUserfollow)
                .where(wzmActivityUserfollow.userId.eq(userId).or(wzmActivityUserfollow.uuid.eq(uuid)));

        return jdbcTemplate.queryForObject(query, wzmActivityUserfollow);
    }
}
